/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.facebook.presto.spi.adaptive;

import com.facebook.presto.spi.TableHandle;
import com.facebook.presto.spi.adaptive.metadata.presto.AdaptivePrestoObject;
import com.facebook.presto.spi.plan.PlanNode;
import com.facebook.presto.spi.plan.PlanNodeIdAllocator;

/**
 * @author wenxu Luo.
 * <p>˙
 * Given a PlanNode, return a transformed PlanNode.
 * (1) Adaptive optimizer check maxSubtree and find out the best engine to execute.
 * (2) Now, the candicate engines include mongodb, hbase, neo4j.
 * (3) Now, we only implement the optimizer based on rules, and you can scale some
 * optimizers based on cost and machine learning later.
 */
public interface ConnectorAdaptiveOptimizer
{
    CatalogEngine getConnectorCatalog();

    default OptimizerType getOptimizerType()
    {
        return OptimizerType.UNSUPPORTED;
    }

    PlanNode adaptiveOptimize(PlanNode node, TableHandle tableHandle, PlanNodeIdAllocator idAllocator, AdaptivePrestoObject adaptiveObject);
}
